import request from '@/utils/request'

/**
 * 获取所有权限点
 */
export const getPermissionList = () => {
  return request({
    url: '/sys/permission'
  })
}

/**
 * 添加权限点
 * @param {*} data 对象
 */
export const addPermission = data => {
  return request({
    url: '/sys/permission',
    method: 'POST',
    data
  })
}

/**
 * 根据ID获取权限点详情
 * @param {*} id {}
 */
export const getPermissionInfo = id => {
  return request({
    url: '/sys/permission/' + id
  })
}

/**
 * 根据ID更新权限点详情
 * @param {*} data 编辑权限
 */
export const updatePermissionInfo = data => {
  return request({
    url: '/sys/permission/' + data.id,
    method: 'PUT',
    data
  })
}

/**
 * 根据id删除权限点
 * @param {*} id id 删除
 */
export const delPermission = id => {
  return request({
    url: '/sys/permission/' + id,
    method: 'DELETE'
  })
}

/**
 * 给角色分配权限
 * @param {*} data 角色id 权限id集合
 */
export const setPermissionToRole = data => {
  return request({
    url: '/sys/role/assignPrem',
    method: 'PUT',
    data
  })
}
